<?php
/**
 * Author:xsc
 * Time:2023/9/20 13:28
 */

namespace App\Repository;

use App\Models\Statistics;

class StatisticsRepo extends BaseRepo
{

    /**
     * 查询某一天的统计信息
     * @param array $special_ids
     * @param string $date
     * @return array
     * Author:xsc
     * Time:2023/9/20 14:03
     */
    public function getDataByIds(array $special_ids, string $date = '')
    {
        $date = $date ?: date('Ymd', strtotime('-1 day'));
        $res = Statistics::query()
            ->whereIn('special_id', $special_ids)
            ->whereRaw("date_format(create_time,'%Y%m%d') = " . $date)
            //->groupBy('special_id')
            //->orderBy('id', 'desc')
            ->get()
            ->toArray();
        return $res;
    }

}
